<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:th="http://www.thymeleaf.org">

<div th:fragment="header">
	<nav class="navbar navbar-default"
		style="background: none repeat scroll 0 0 #394755; color: #fff; height: 60px;">
		<div class="container-fluid">
			<!-- Brand and toggle get grouped for better mobile display -->
			<div class="navbar-header" style="margin-right: 20%;">
				<a class="navbar-brand" href="/mainframe" style="color: #fff;">Blog后台管理</a>
			</div>
			<!-- 退出 -->
			<a class="navbar-brand" href="#" style="color: #fff; float: right;"
				onclick="javascript:safeLogoutFun();">退出</a>
			<!-- 欢迎语 -->
			<div class="navbar-brand"
				style="margin-right: 30px; font-size: 15px; float: right; color: #f5d313;">
				欢迎您,<span>亲爱的用户 <span th:text="${session.username}"></span></span> 现在是 <span id="time"></span>
				<script th:inline="javascript">
					/*<![CDATA[*/
					function setTime() {
						var dt = new Date();
						var arr_week = new Array("星期日", "星期一", "星期二", "星期三",
								"星期四", "星期五", "星期六");
						var strWeek = arr_week[dt.getDay()];
						var strHour = dt.getHours();
						var strMinutes = dt.getMinutes();
						var strSeconds = dt.getSeconds();
						if (strMinutes < 10)
							strMinutes = "0" + strMinutes;
						if (strSeconds < 10)
							strSeconds = "0" + strSeconds;
						var strYear = dt.getFullYear() + "年";
						var strMonth = (dt.getMonth() + 1) + "月";
						var strDay = dt.getDate() + "日";
						var strTime = strHour + ":" + strMinutes + ":"
								+ strSeconds;
						time.innerHTML = strYear + strMonth + strDay + " "
								+ strTime + "  " + strWeek;
					}
					setInterval("setTime()", 100);

					function safeLogoutFun() {
						if (confirm("确定需要退出吗？")) {
							$.ajax({
								type : "POST",
								url : "/loginout",
								dataType : "json",
								error : function(e) {
									console.log(e);
								},
								success : function(responseInfo) {
									if (responseInfo.status) {
										window.location.replace("/login");
										//window.event.returnValue = false;//取消默认事件的处理
									}
									if (!responseInfo.status) {
										alert(responseInfo.message);
									}
								}
							});//end ajax
						}//end if confirm
					}
					/*]]>*/
				</script>
			</div>
		</div>
	</nav>
</div>
</html>